<template>
  <div>
    <div id="leftOne"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      setData: [
        {
          title: "参数",
          val: 120,
        },
        {
          title: "参数",
          val: 200,
        },
        {
          title: "参数",
          val: 170,
        },
        {
          title: "参数",
          val: 130,
        },
        {
          title: "参数",
          val: 150,
        },
        {
          title: "参数",
          val: 110,
        },
        {
          title: "参数",
          val: 210,
        },
      ],
    };
  },
  mounted() {
    this.initCanvas();
  },
  methods: {
    initCanvas() {
      let myChart = this.$echarts.init(document.getElementById("leftOne"));
      myChart.setOption({
        color: ["#2f89cf"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        grid: {
          left: "10%",
          top: "10%",
          right: "10%",
          bottom: "10%",
          containLable: true,
        },
        xAxis: {
          type: "category",
          data: this.setData.map((item, index) => item.title + index),
          axisLabel: {
            color: "rgba(255,255,255,.6)",
            fontSize: 12,
          },
          axisTick: {
            show: false,
          },
        },
        yAxis: {
          type: "value",
          axisLabel: {
            color: "rgba(255,255,255,.6)",
            fontSize: 12,
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              color: "rgba(255,255,255,.1)",
              width: 2,
            },
          },
          splitLine: {
            lineStyle: {
              color: "rgba(255,255,255,.1)",
            },
          },
        },
        series: [
          {
            data: this.setData.map((item) => item.val),
            type: "bar",
            barWidth: "35%",
            itemStyle: {
              barBorderRadius: 5,
            },
          },
        ],
      });
    },
  },
};
</script>

<style lang="less" scoped>
#leftOne {
  height: 240px;
}
</style>